<script setup lang="ts">
const route = useRoute()
const router = useRouter()
const params = route.params
const path = params?.path ? decodeURIComponent(params.path as string) : ''

// 确保使用绝对路径，避免相对路径导致再次进入 /redirect
if (path) {
  const target = path.startsWith('/') ? path : `/${path}`
  // 防止跳转到 /redirect 开头的路径造成循环
  if (target.startsWith('/redirect')) {
    router.replace('/')
  } else {
    router.replace(target)
  }
} else {
  router.replace('/')
}
</script>

<template>
  <div>
    <h1>Redirecting...</h1>
  </div>
</template>
